package cn.itsource.pethome.system.controller;

import cn.itsource.pethome.base.controller.BaseController;
import cn.itsource.pethome.system.domain.DictionaryType;
import cn.itsource.pethome.system.service.IDictionaryTypeService;
import cn.itsource.pethome.util.AjaxResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/type")
@Api(value = "数据字典相关的",description="数据字典相关的CRUD功能")
public class DictionaryTypeController extends BaseController<DictionaryType> {
    @Autowired
    private IDictionaryTypeService dictionaryTypeService;

    @PostMapping("/save")
    public AjaxResult save(@RequestBody DictionaryType dictionaryType){
        try {
            if(dictionaryType.getId()==null){
                dictionaryTypeService.insert(dictionaryType);
            }else {
                dictionaryTypeService.update(dictionaryType);
            }
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error();
        }
    }
}
